package  
{
	import bulletbehavior.RotateBehavior;
	import bulletbehavior.SetAngleBehavior;
	import bulletbehavior.TypeCyclingBehavior;
	import bulletbehavior.WaveBehavior;
	import turretbehavior.SpeedModulationBehavior;
	import turretbehavior.SpinningTurretBehavior;
	import turretbehavior.TypeCyclingTurretBehavior;
	import org.flixel.FlxG;
	/**
	 * ...
	 * @author morgan
	 */
	public class Stage5State extends GameState
	{
		
		public function Stage5State() 
		{
			super();
			levelName = "2-2";
			levelIndex = 4;
			chefName = "sir bisque";
			img_terrain = img_terrain_2;			
		}
		
		override public function setupBoss():void 
		{
			boss = new Boss(FlxG.width / 2 - 70, 10, 1);
			
			var straight:BulletPattern = new BulletPattern();
			
			var p1f:BossPattern = new BossPattern();
			var t1t:Turret = new Turret(0, -50, straight, 0, 90, 30, 0.025, true);
			t1t.addBehavior(new TypeCyclingTurretBehavior(0.2, [0, 1, 2]));
			t1t.addBehavior(new SpinningTurretBehavior(360, 1800, true));
			//t1t.addBehavior(new SpeedModulationBehavior(10, 0.1));
			p1f.addTurretTime(0, Infinity, t1t);
			
			var p2f:BossPattern = new BossPattern();
			for (var i:int = 0; i < 14; i++)
			{
				var a:Number = i * 6.2818 / 14;
				var spin:BulletPattern = new BulletPattern();
				spin.addBehavior(new WaveBehavior(3, 20, 0, a - Math.PI, true));
				spin.addBehavior(new WaveBehavior(3, 0, 20, a - Math.PI + Math.PI / 2, true));
				var tt:Turret = new Turret(Math.sin(a) * 20, Math.cos(a) * 20, spin, i % 3, 90, 40, 1.5);
				p2f.addTurretTime(0, Infinity, tt);
			}
			
			var t2t:Turret = new Turret(0, 0, straight, Bullet.CANDY, 90, 40, 1.5);
			p2f.addTurretTime(0, Infinity, t2t);
			
			var p3f:BossPattern = new BossPattern();
			for (i = 0; i < 11; i++)
			{
				tt = new Turret((i - 5) * 10, Math.abs(i-5) * -10 + 30, straight, 0, 90 + (i - 5) * -2, Math.abs(i - 5) * 10 + 70, 0.8);
				tt.addBehavior(new TypeCyclingTurretBehavior(0.4, [Math.abs(i-5) % 3, (Math.abs(i-5)+1) % 3, (Math.abs(i-5)+2) % 3]));
				p3f.addTurretTime(0, Infinity, tt);
			}
			
			var p4f:BossPattern = new BossPattern();
			var t3t:Turret = new Turret(0, -70, straight, 0, 90, 30, 0.1, true);
			t3t.addBehavior(new SpinningTurretBehavior(180));
			p4f.addTurretTime(0, Infinity, t3t);
			var t4t:Turret = new Turret(70, 100, straight, 1, -120, 35, 0.1, true);
			t4t.addBehavior(new SpinningTurretBehavior(200));
			p4f.addTurretTime(0, Infinity, t4t);			
			var t5t:Turret = new Turret(-70, 100, straight, 2, -60, 25, 0.1, true);
			t5t.addBehavior(new SpinningTurretBehavior(120));
			p4f.addTurretTime(0, Infinity, t5t);		
			
			var t6t:Turret = new Turret(0, -70, straight, 1, 90, 10, 1.0, true); t6t.addBehavior(new SpinningTurretBehavior(45));
			var t7t:Turret = new Turret(70, 100, straight, 2, 90, 10, 1.0, true); t7t.addBehavior(new SpinningTurretBehavior(45));
			var t8t:Turret = new Turret(-70, 100, straight, 0, 90, 10, 1.0, true); t8t.addBehavior(new SpinningTurretBehavior(45));
			p4f.addTurretTime(1, Infinity, t6t);
			p4f.addTurretTime(1, Infinity, t7t);
			p4f.addTurretTime(1, Infinity, t8t);
			
			boss.addState(new BossState(1200, p1f));
			boss.addState(new BossState(1400, p2f));
			boss.addState(new BossState(800, p3f));
			boss.addState(new BossState(1300, p4f));
		}
		
	}

}